#!/bin/sh -e

mkdir -p packages

cd mac
rm -rf "build/Release Binary"
rm -rf "build/Release Decimal"
xcodebuild -project Free42.xcodeproj -target Free42 -configuration "Release Binary" build
xcodebuild -project Free42.xcodeproj -target Free42 -configuration "Release Decimal" build
mkdir tmp
mv "build/Release Binary/Free42.app" "tmp/Free42 Binary.app"
mv "build/Release Decimal/Free42.app" "tmp/Free42 Decimal.app"
cp README.txt tmp
cd tmp
zip -r ../../packages/Free42Mac.zip "Free42 Binary.app" "Free42 Decimal.app" README.txt
cd ..
rm -rf tmp
cd ..

unset BCD_MATH
cd macdashboard
make clean
make
zip -r ../Free42Binary.zip Free42.wdgt
make clean
make -e BCD_MATH=1
zip -r ../Free42Decimal.zip Free42.wdgt
cd ..
zip packages/Free42MacDashboard.zip Free42Binary.zip Free42Decimal.zip
rm Free42Binary.zip Free42Decimal.zip
